package com.yidianyanglao.core.util;

/**
 *
 * Created by chenkelong on 2016/12/23.
 *  验证正则表达式
 */
public class VerificationRegular {

    public static String REGEX = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$";

    /*
     * 验证登录密码复杂度
     */
    public static boolean checkLoginPassword(String password){

        if(!password.matches(REGEX)){
            return false;
        }
        return true;


    }

    //验证支付密码不能使123456,654321，或者六位一样的数据
    public static boolean checkPayPassword(String paypassword){
        if(paypassword.equals("123456") || paypassword.equals("654321")){
            return false;
        }
        int count = 0;
        char[] a = paypassword.toCharArray();
        for(int i=0;i<a.length;i++){
            if(a[0] == a[i])count ++;
        }
        if(count>=6){
            return false;
        }
        return true;

    }

    public static void main(String[] args){
        System.out.println(checkPayPassword("123456"));
    }

}
